// 定义记分牌的类
class ScorePanel {
  score: number = 0
  level = 1
  scoreEle: HTMLElement
  levelEle: HTMLElement
  // 设置最大等级
  maxLevel: number
  // 设置多少分升级
  upScore: number
  constructor(maxLevel: number = 10, upScore: number = 10) {
    this.maxLevel = maxLevel
    this.upScore = upScore
    this.scoreEle = document.getElementById('score')!
    this.levelEle = document.getElementById('level')!
  }
  // 设置加分方法
  addScore() {
    this.score++
    this.scoreEle.innerHTML = this.score + ''
    if (this.score % this.upScore === 0) {
      this.addLevel()
    }
  }
  // 提升等级方法
  addLevel() {
    if (this.level < this.maxLevel) {
      this.level++
      this.levelEle.innerHTML = this.level + ''
    }
  }
}

export default ScorePanel
